import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import {toast} from 'nc-lightapp-front'
import updateSubButtonStatus from "./updateSubButtonStatus";

export default function saveLine(isSynWork, isdisablepsn) {
    const {areaCode} = this.state;
    const {isInJob, selectedPsn, pageid, orgVal, editTable, disabledAllArea, getMainTableData} = this.props;
    const changedRows = editTable.getChangedRows(areaCode);
    if (!changedRows) return;
    let postData = {
        areaCode,
        editType: this.editType,
        isInJob,
        pk_org: orgVal.refpk,
        pk_psnjob: selectedPsn,
        isSynWork,
        isdisablepsn,
        curRow: {areacode: areaCode, rows: changedRows},
    };

    proFetch({
        url: '/nccloud/hrtrn/pub/RecordsSaveDoAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                toast({color: "success", content: this.props.json['hi6007-000000']});
                editTable.setStatus(areaCode, 'browse');
                disabledAllArea(false);
                updateSubButtonStatus.call(this, false);
                //this.getSubTableData(selectedPsn);
                getMainTableData(true);
            }
        });
}
